using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations.Schema;
using SalesPages.DomainModel;

namespace SalesPages.EntityFrameworkRepository.Mapping
{
    public class MapSettingMap : EntityTypeConfiguration<MapSetting>
    {
        public MapSettingMap()
        {
            // Primary Key
            this.HasKey(t => new { t.ID, t.InsertDate, t.UpdateDate });

            // Properties
            this.Property(t => t.ID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(t => t.Country)
                .HasMaxLength(2);

            this.Property(t => t.City)
                .HasMaxLength(50);

            this.Property(t => t.Key)
                .HasMaxLength(50);

            this.Property(t => t.Value)
                .HasMaxLength(50);

            this.Property(t => t.SchoolCode)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("MapSetting");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.Country).HasColumnName("Country");
            this.Property(t => t.City).HasColumnName("City");
            this.Property(t => t.Key).HasColumnName("Key");
            this.Property(t => t.Value).HasColumnName("Value");
            this.Property(t => t.CourseType).HasColumnName("CourseType");
            this.Property(t => t.InsertDate).HasColumnName("InsertDate");
            this.Property(t => t.UpdateDate).HasColumnName("UpdateDate");
            this.Property(t => t.SchoolCode).HasColumnName("SchoolCode");
        }
    }
}
